home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / dev / e / amigae33a.lha / E_v3.3a / Src.lha / Src / OOmodules / library / reqtools.e < prev   
Text File  |  1996-02-03  |  6KB  |  275 lines

  1. OPT MODULE
  2. OPT EXPORT
  3.  
  4. MODULE 'oomodules/library', 'reqtools', 'libraries/reqtools'
  5.  
  6. CONST FILEREQ=0
  7.  
  8. -> NOTE: some modifications by JEVR3 here and there.
  9.  
  10. OBJECT reqtools OF library
  11. /****** library/--library-- ******************************************
  12.  
  13.     NAME 
  14.         library of object
  15.  
  16.     PURPOSE
  17.         Basic implementation of a simple library module.
  18.  
  19.     ATTRIBUTES
  20.         stringbuf -- Address of the buffer for the last character input.
  21.  
  22.         filebuf -- Address of the buffer for the last file choice.
  23.  
  24.         dirbuf -- Address of the buffer for the last directory choice.
  25.  
  26.         number -- Address of the variable that contains the last number
  27.             entered.
  28.  
  29.     CREATION
  30.         Back in February of 1995 by Gregor Goldbach
  31.  
  32.     HISTORY
  33.  
  34. ******************************************************************************
  35.  
  36. History
  37.  
  38.  
  39. */
  40.   stringbuf
  41.   filebuf
  42.   dirbuf
  43.   number
  44. ENDOBJECT
  45.  
  46. -> JEVR3 addition: init() sets 'reqtools.library' and no version.
  47.  
  48. PROC init() OF reqtools
  49. /****** reqtools/init ******************************************
  50.  
  51.     NAME 
  52.         init() -- Initialization of the object.
  53.  
  54.     SYNOPSIS
  55.         reqtools.init()
  56.  
  57.     FUNCTION
  58.         Sets the library's name and the version to 0. After that the library
  59.         is opened.
  60.  
  61.     SEE ALSO
  62.         open()
  63. ******************************************************************************
  64.  
  65. History
  66.  
  67.  
  68. */
  69.  self.identifier:='reqtools.library'
  70.  self.version:=0
  71.  self.open()
  72. ENDPROC
  73.  
  74. -> JEVR3 modification: made it one-line (I'm demented)
  75.  
  76. PROC open() OF reqtools
  77. /****** reqtools/open ******************************************
  78.  
  79.     NAME 
  80.         open() -- Open reqtools.library
  81.  
  82.     SYNOPSIS
  83.         reqtools.open()
  84.  
  85.     FUNCTION
  86.         Opens the reqtools.library.
  87.  
  88.     EXCEPTIONS
  89.         "lib",{reqtoolOpen} will be raised if the opening fails.
  90.  
  91. ******************************************************************************
  92.  
  93. History
  94.  
  95.  
  96. */
  97.  IF (reqtoolsbase:=OpenLibrary(self.identifier,self.version)) = NIL THEN Throw("lib",{reqtoolOpen})
  98. ENDPROC
  99.  
  100. PROC ez(body,gadgets,dunno=NIL,arglist=NIL,taglist=NIL) OF reqtools
  101. /****** reqtools/ez ******************************************
  102.  
  103.     NAME 
  104.         ez() -- Display an eazy requester.
  105.  
  106.     SYNOPSIS
  107.         reqtools.ez(LONG,LONG,LONG=NIL,LONG=NIL,LONG=NIL)
  108.  
  109.     FUNCTION
  110.         Displays one of those nice ez requesters. Refer to the reqtools
  111.         documentation for input details.
  112.  
  113. ******************************************************************************
  114.  
  115. History
  116.  
  117.  
  118. */
  119.  
  120.   IF reqtoolsbase
  121.     RETURN RtEZRequestA(body,gadgets,dunno,arglist,taglist)
  122.   ENDIF
  123. ENDPROC
  124.  
  125. -> JEVR3 modification; string() returns stringbuf, New() now String()
  126.  
  127. PROC string(title=NIL,maxlen=200,dunno=NIL,dunno2=NIL) OF reqtools
  128. /****** reqtools/string ******************************************
  129.  
  130.     NAME 
  131.         string() -- Asks for a character input.
  132.  
  133.     SYNOPSIS
  134.         reqtools.string(LONG=NIL,LONG=NIL,LONG=NIL,LONG=NIL)
  135.  
  136.     FUNCTION
  137.         Asks for a string input. For further documentation refer to the
  138.         reqtools document.
  139.  
  140.     RESULT
  141.         PTR TO CHAR -- Address of the string entered.
  142.  
  143. ******************************************************************************
  144.  
  145. History
  146.  
  147.  
  148. */
  149.   IF self.stringbuf THEN Dispose(self.stringbuf)
  150.   self.stringbuf := String(maxlen)
  151.  
  152.   RtGetStringA(self.stringbuf,maxlen,title,dunno,dunno2)
  153. ENDPROC self.stringbuf
  154.  
  155. -> JEVR3 modification; changed 'end()' to 'close()'.  'end()' still works,
  156. -> since it calls 'self.close()'
  157.  
  158. PROC close() OF reqtools
  159. /****** reqtools/close ******************************************
  160.  
  161.     NAME 
  162.         close() -- Close the library.
  163.  
  164.     SYNOPSIS
  165.         reqtools.close()
  166.  
  167.     FUNCTION
  168.         Closes the library.
  169.  
  170.     SEE ALSO
  171.         open()
  172. ******************************************************************************
  173.  
  174. History
  175.  
  176.  
  177. */
  178.   IF self.stringbuf THEN DisposeLink(self.stringbuf)
  179.   CloseLibrary(reqtoolsbase)
  180. ENDPROC
  181.  
  182. PROC palette(title,dunno=NIL,dunno2=NIL) OF reqtools
  183. /****** reqtools/palette ******************************************
  184.  
  185.     NAME 
  186.         palette() -- Pop up palette requester.
  187.  
  188.     SYNOPSIS
  189.         reqtools.palette(LONG,LONG=NIL,LONG=NIL)
  190.  
  191.     FUNCTION
  192.         Display reqtools' palette requester.
  193.  
  194.     RESULT
  195.         number of colour chosen.
  196.  
  197. ******************************************************************************
  198.  
  199. History
  200.  
  201.  
  202. */
  203.   self.number :=  RtPaletteRequestA(title,dunno,dunno2)
  204. ENDPROC self.number
  205.  
  206. PROC long(title,number=NIL,dunno=NIL,dunno2=NIL) OF reqtools
  207. /****** reqtools/long ******************************************
  208.  
  209.     NAME
  210.         long() -- Pop up long integer requester.
  211.  
  212.     SYNOPSIS
  213.         reqtools.long(LONG,LONG=NIL,LONG=NIL,LONG=NIL)
  214.  
  215.     FUNCTION
  216.         Display a requester that asks for a long integer to be entered.
  217.         For more documentation refer to the reqtools manual.
  218.  
  219. ******************************************************************************
  220.  
  221. History
  222.  
  223.  
  224. */
  225.   RtGetLongA({number}, title, dunno, dunno2)
  226.   self.number := number
  227. ENDPROC self.number
  228.  
  229. PROC file(title,maxlen=200,tags=NIL) OF reqtools HANDLE
  230. /****** reqtools/file ******************************************
  231.  
  232.     NAME 
  233.         file() -- Get file via requester.
  234.  
  235.     SYNOPSIS
  236.         reqtools.file(PTR TO CHAR,LONG)
  237.  
  238.     RESULT
  239.         TRUE if a file was selected, FALSE otherwise. See reqtools.doc
  240.         for more info.
  241.  
  242.     FUNCTION
  243.         Select a file via file requester. The file and directory choices
  244.         are copied to the according attributes.
  245.  
  246. ******************************************************************************
  247.  
  248. History
  249.  
  250.  
  251. */
  252. DEF req:PTR TO rtfilerequester,
  253.     result
  254.  
  255.   IF req:=RtAllocRequestA(FILEREQ,0)
  256.  
  257.     IF self.filebuf THEN Dispose(self.filebuf)
  258.     IF self.dirbuf THEN Dispose(self.dirbuf)
  259.     self.filebuf := NewR(maxlen)
  260.     self.dirbuf := NewR(maxlen)
  261.  
  262.      result := RtFileRequestA(req,self.filebuf,title,tags)
  263.      AstrCopy(self.dirbuf,req.dir,maxlen)
  264.      RtFreeRequest(req)
  265.   ENDIF
  266.  
  267.   RETURN result
  268.  
  269. EXCEPT
  270.   NOP
  271. ENDPROC
  272.  
  273. reqtoolOpen:
  274.  CHAR 'Unable to open reqtools.library.',0
  275.